import { PageAttr, SiteAttr, ComponentTypes } from '@/store/default-styles'
import { guid, isHasOwnProperty } from '@/plugins/utils'
import { COMPONENT_TYPES, PAGE_TYPE, CONTROL_TYPES } from '@/common/const'
import { MOBILE_WID_HEI, MOBILE_WID_HEI_, PC_WID_HEI, CANVAS_WID_HEI, H5_TYPE } from '@/common/const-dif'
import { getEventByControlId } from '@/common/events'
import { ADD_COMP_ATTR } from '@/store/default-styles-dom'
import { getPxOVwByValue } from '@/store/utils'
import { bgPositionStyle } from '@/store/utils'

export function initSiteData(data, isEditSite, siteStatus, componentFrontAttr, fileUploadData){
  if(isEditSite){
    siteStatus.scale = 1
    if(localStorage.isHighComponentConfiguration) {
      siteStatus.isHighComponentConfiguration = JSON.parse(localStorage.isHighComponentConfiguration)
    }
  }
  if(!data || !data.pages) {
    let site =  _.cloneDeep(SiteAttr);
    let pageAttr = _.cloneDeep(PageAttr);
    pageAttr.attrs.width = MOBILE_WID_HEI.width;
    pageAttr.attrs.height = MOBILE_WID_HEI.height;
    site.id = data.id;
    site.pages = [
      pageAttr
    ];
    site.attrs.h5Type = data.tag;
    site.pages[0].id = guid();
    data = site;
  }
  let h5Type = data.attrs.h5Type
  let page = data.pages[0]
  if(h5Type == H5_TYPE.mobile){
    MOBILE_WID_HEI.width = page.attrs.width
    _.merge(MOBILE_WID_HEI, MOBILE_WID_HEI_)
  }else if(h5Type == H5_TYPE.pc){
    PC_WID_HEI.width = page.attrs.width
    _.merge(MOBILE_WID_HEI, PC_WID_HEI)
  }else if(h5Type == H5_TYPE.canvas){
    CANVAS_WID_HEI.width = page.attrs.width
    _.merge(MOBILE_WID_HEI, CANVAS_WID_HEI)
    data.attrs.width = MOBILE_WID_HEI.clientWidth
    data.attrs.height = MOBILE_WID_HEI.clientHeight
  }
  
  const swiper = SiteAttr.attrs.swiper
  if(!isHasOwnProperty(data.attrs, 'swiper')) {
    data.attrs.swiper = _.cloneDeep(swiper)
  }
  _.forEach(swiper, (value, key) => {
    data.attrs.swiper[key] = data.attrs[key]
  })
  _.forEach(swiper, (value, key) => {
    delete data.attrs[key]
  })
  delete data.attrs.gradients
  delete data.attrs.gradientAngle
  // delete data.attrs.controlData

  for(let i = 0, pageLen = data.pages.length; i < pageLen; i++) {
    let page = data.pages[i]
    page.attrs.isDisplayBtns = false
    dealPageAttrs(page)
    //处理组件
    for(let j = 0, len = page.components.length; j < len; j++) {
      let componentData = page.components[j];
      if(isEditSite && !isHasOwnProperty(componentFrontAttr, componentData.id)) {
        componentFrontAttr[componentData.id] = {isHidden: false, isLock: false}
      }
      recursionDealComponent(componentData, siteStatus)
    }
  }
  data.attrs.isVisiblePhone = true
  data.attrs.isCurrentPage = true
  data.attrs.isPeripheralVisible = true
  if(data.attrs.pageType == PAGE_TYPE.long) {
    data.attrs.isVisiblePhone = false
  }
  if(isEditSite && fileUploadData) {
    fileUploadData.site_id = data.id
  }
  return data
}
export function initComponentMap(componentMap, pageOrGroupComponent) {
  _.forEach(pageOrGroupComponent.components, (componentData) => {
    componentMap[componentData.id] = componentData;
    if(componentData.components && componentData.components.length > 0){
      initComponentMap(componentMap, componentData);
    }
  })
}
export function saveDealSiteData(controls, siteData) {
  siteData.activityInfo.isHave = false
  siteData.activityInfo.compId = ''
  const componentMap = {}
  _.forEach(siteData.pages, (page) => {
    initComponentMap(componentMap, page)
  })
  const controls_ = {}
  setControlElementsId(controls, controls_, componentMap)
  const pages = siteData.pages
  let page
  for(let i = 0, pageLen = pages.length; i < pageLen; i++) {
    page = pages[i]
    delete page.attrs.isDisplayBtns
    delete page.attrs.isCurrentPage
    delete page.styles
    saveSiteDataBeforeDealData(page.components, siteData)
    componentDataDeleteAttr(page)
  }
  const attrs = siteData.attrs
  delete attrs.isPeripheralVisible
  delete attrs.isVisiblePhone
  delete attrs.isCurrentPage
  let data = { pages, attrs, controls: controls_, id: siteData.id, activityInfo: siteData.activityInfo }
  window.localStorage.siteData = JSON.stringify(data)
  return data
}

function dealPageAttrs(page) {
  const attrs = page.attrs
  const styles = page.styles
  delete attrs.gradients
  delete attrs.gradientAngle
  delete attrs.isGradient

  if(styles) {
    if(isHasOwnProperty(styles, 'backgroundColor')) {
      attrs.backgroundColor = styles.backgroundColor
    }
  }
}
function recursionDealComponent(componentData, siteStatus) {
  //新加的字段 兼容性处理
  newlyIncreasedAttr(componentData)
  dealCompatibilityData(componentData, siteStatus)
  if(componentData.components && componentData.components.length > 0) {
    _.forEach(componentData.components, (componentData_) => {
      recursionDealComponent(componentData_, siteStatus)
    })
  }
}
  //递归处理新增字段
function newlyIncreasedAttr(componentData) {
  componentDataNewAttr(componentData)
  if(componentData.components && componentData.components.length > 0) {
    _.forEach(componentData.components, (componentData_) => {
      newlyIncreasedAttr(componentData_)
    })
  }
}
function componentDataNewAttr(componentData) {
  if(!isHasOwnProperty(componentData, "events") || _.isArray(componentData.events)) {
    componentData.events = {}
  }
  if(!isHasOwnProperty(componentData, "animate")) {
    componentData.animate = {}
    _.merge(componentData.animate, ADD_COMP_ATTR.animate)
  }
  // 递归恢复删除字段
  const oriComponentData = getComponentDataByCid(componentData.cid)
  if(!oriComponentData) return
  _.forEach(oriComponentData, (value, key) => {
    if(_.isObject(oriComponentData[key])) {
      if(key == "conAttr") {
        const conAttr = componentData.conAttr
        const conStyles = _.cloneDeep(ADD_COMP_ATTR.conStyles)
        _.forEach(conStyles, (value, key) => {
          if(key == 'zIndex' || key == 'position') {
            if(isHasOwnProperty(conAttr, key)) {
              conStyles[key] = conAttr[key]
            }
          } else {
            conStyles[key] = getPxOVwByValue(conAttr[key])          
          }
        })
        if(componentData.conStyles && isHasOwnProperty(componentData.conStyles, 'zIndex')) {
          conStyles.zIndex = componentData.conStyles.zIndex
          componentData.conAttr.zIndex = componentData.conStyles.zIndex
        }
        componentData.conStyles = conStyles
      } else if(key == "commonAttr") {
        let oriCommonAttr = {}
        _.merge(oriCommonAttr, ADD_COMP_ATTR.commonAttr)
        _.merge(oriCommonAttr, oriComponentData.commonAttr)
        let commonAttr = componentData.commonAttr
        _.forEach(oriCommonAttr, (value, key) => {
          if(!isHasOwnProperty(commonAttr, key)) {
            commonAttr[key] = value
          }
        })
      }
    }else if(!isHasOwnProperty(componentData, key)) {
      componentData[key] = value
    }
    delete componentData.icon
    delete componentData.isProduction
  })
  // let eventMap = getEventsMap()
  // _.forEach(componentData.events, (event) => {
  //   let oriEvent = eventMap[event.type]
  //   _.forEach(oriEvent, (value, key) => {
  //     if(!isHasOwnProperty(event, key)) {
  //       event[key] = value
  //     }
  //     _.forEach(oriEvent.comps, (comp, index) => {
  //       if(!event.comps[index]) {
  //         event.comps.push(_.cloneDeep(comp))
  //       }
  //     })
  //   })
  // })
}
function dealCompatibilityData(componentData, siteStatus) {
  if(componentData.btn) {
    dealCompatibilityData(componentData.btn)
  }
  const commonAttr = componentData.commonAttr
  if(commonAttr.itemMarginTB == 0 && commonAttr.marginTB != 0) {
    commonAttr.itemMarginTB = commonAttr.marginTB
  }
  if(commonAttr.itemMarginLR == 0 && commonAttr.marginLR != 0) {
    commonAttr.itemMarginLR = commonAttr.marginLR
  }
  if(commonAttr.itemMarginTB >= 0) commonAttr.marginTB = commonAttr.itemMarginTB
  if(commonAttr.itemMarginLR >= 0) commonAttr.marginLR = commonAttr.itemMarginLR
  if(commonAttr.itemPaddingTB >= 0) commonAttr.paddingTB = commonAttr.itemPaddingTB
  if(commonAttr.itemPaddingLR >= 0) commonAttr.paddingLR = commonAttr.itemPaddingLR
  //兼容之前的数据
  if(commonAttr.paddingTB >= 0 || commonAttr.paddingLR >= 0) {
    if(!isHasOwnProperty(commonAttr, 'paddingTB')) {
      commonAttr.paddingTB = 0
    }
    if(!isHasOwnProperty(commonAttr, 'paddingLR')) {
      commonAttr.paddingLR = 0
    }
  }
  if(commonAttr.marginTB >= 0 || commonAttr.marginLR >= 0) {
    if(!isHasOwnProperty(commonAttr, 'marginTB')) {
      commonAttr.marginTB = 0
    }
    if(!isHasOwnProperty(commonAttr, 'marginLR')) {
      commonAttr.marginLR = 0
    }
  }
  if(commonAttr.paddingTB >= 0 || commonAttr.paddingLR >= 0) {
    commonAttr.padding = commonAttr.paddingTB + ' ' + commonAttr.paddingLR + ' ' + commonAttr.paddingTB + ' ' + commonAttr.paddingLR
  }
  if(commonAttr.marginTB >= 0 || commonAttr.marginLR >= 0) {
    commonAttr.margin = commonAttr.marginTB + ' ' + commonAttr.marginLR + ' ' + commonAttr.marginTB + ' ' + commonAttr.marginLR
  }
  delete commonAttr.itemMarginTB
  delete commonAttr.itemMarginLR
  delete commonAttr.itemPaddingTB
  delete commonAttr.itemPaddingLR
  delete commonAttr.marginTB
  delete commonAttr.marginLR
  delete commonAttr.paddingTB
  delete commonAttr.paddingLR
  if(commonAttr.itemWidth >= 0) {
    commonAttr.width = commonAttr.itemWidth
    delete commonAttr.itemWidth
  }
  if(commonAttr.itemHeight >= 0) {
    commonAttr.height = commonAttr.itemHeight
    delete commonAttr.itemHeight
  } 
  delete commonAttr.itemWidth
  delete commonAttr.itemHeight
  if(commonAttr.itemBGWidth >= 0 || commonAttr.itemBgWidth >= 0) commonAttr.bgWidth = commonAttr.itemBGWidth || commonAttr.itemBgWidth
  if(commonAttr.itemBGHeight >= 0 || commonAttr.itemBgHeight >= 0) commonAttr.bgHeight = commonAttr.itemBGHeight || commonAttr.itemBgHeight
  if(commonAttr.itemBGUrl || commonAttr.itemBgUrl) commonAttr.bgUrl = commonAttr.itemBGUrl || commonAttr.itemBgUrl
  if(commonAttr.itemBGColor) commonAttr.bgColor = commonAttr.itemBGColor
  if(commonAttr.selectedBGUrl || commonAttr.selectedBgUrl) commonAttr.selectedBgUrl = commonAttr.selectedBGUrl || commonAttr.selectedBgUrl
  if(commonAttr.selectedBackgroundColor || commonAttr.selectedBGColor) commonAttr.selectedBgColor = commonAttr.selectedBackgroundColor || commonAttr.selectedBGColor
  delete commonAttr.itemBGWidth
  delete commonAttr.itemBgWidth
  delete commonAttr.itemBGHeight
  delete commonAttr.itemBgHeight
  delete commonAttr.itemBGUrl
  delete commonAttr.itemBgUrl
  delete commonAttr.itemBGColor
  delete commonAttr.selectedBackgroundColor
  delete commonAttr.selectedBGColor
  if(commonAttr.itemBorderSize >= 0) {
    commonAttr.borderColor = commonAttr.itemBorderColor
    commonAttr.borderSize = commonAttr.itemBorderSize
    commonAttr.borderStyle = commonAttr.itemBorderStyle
  }  
  if(commonAttr.itemBorderRadius >= 0) commonAttr.borderRadius = commonAttr.itemBorderRadius
  delete commonAttr.itemBorderSize
  delete commonAttr.itemBorderColor
  delete commonAttr.itemBorderStyle
  delete commonAttr.itemBorderRadius
  if(componentData.cid == COMPONENT_TYPES.wb_upload || componentData.cid == COMPONENT_TYPES.wb_camera) {
    if(!isHasOwnProperty(commonAttr, 'saveImgType')) {
      commonAttr.saveImgType = SAVE_IMG_DATA_TYPES[0].value
      commonAttr.saveImgQuality = 0.8
    }
  } else if(componentData.cid == COMPONENT_TYPES.wb_radio || componentData.cid == COMPONENT_TYPES.wb_checkbox) {
    if(commonAttr.selectedStyles && commonAttr.selectedStyles.backgroundColor == 'rgba(0, 0, 0, 0)') {
      commonAttr.selectedStyles.backgroundColor = '#2c7ad2'
    }
    // if(commonAttr.backgroundColor == 'rgba(0, 0, 0, 0)' || commonAttr.backgroundColor == 'rgba(255, 255, 255, 1)') {
    //   commonAttr.backgroundColor = 'rgba(255, 255, 0, 0.2)'
    // }
    if(commonAttr.itemStyles) {
      commonAttr.color = commonAttr.itemStyles.color
      commonAttr.backgroundColor = commonAttr.itemStyles.backgroundColor
      commonAttr.lineHeight = commonAttr.itemStyles.lineHeight
      commonAttr.letterSpacing = commonAttr.itemStyles.letterSpacing
    } 
    delete componentData.styles
  } else if (componentData.cid == COMPONENT_TYPES.wb_bg) {
    if(componentData.styles) {
      const bgColor = componentData.styles.backgroundColor
      if(bgColor && bgColor.indexOf('rgba') != -1) {
        const colors = bgColor.replace('rgba(', '').replace(')', '').split(',')
        if(colors && (colors[3] && Number(colors[3]) < 1 || colors[0] != 255 || colors[0] != 0)) {
          commonAttr.backgroundColor = componentData.styles.backgroundColor
        } else {
          // commonAttr.backgroundColor = 'rgba(0, 0, 0, 0)'
        }
      } else {
        commonAttr.backgroundColor = 'rgba(0, 0, 0, 0)'
      }
    }
  } else if(componentData.cid == COMPONENT_TYPES.wb_is_post_event) {
    if(commonAttr.checkboxUrl) {
      commonAttr.backgroundColor = 'rgba(0, 0, 0, 0)'
    }
    if(isHasOwnProperty(commonAttr, 'checkboxSelectedUrl')) {
      commonAttr.selectedCheckboxUrl = commonAttr.checkboxSelectedUrl
      delete commonAttr.checkboxSelectedUrl
    }
    if(isHasOwnProperty(commonAttr, 'checkboxFontSize')) {
      commonAttr.fontSize = commonAttr.checkboxFontSize
      delete commonAttr.checkboxFontSize
    }
  }
  if (componentData.cid == COMPONENT_TYPES.wb_text || componentData.cid == COMPONENT_TYPES.wb_input || componentData.cid == COMPONENT_TYPES.wb_dropdown || 
    componentData.cid == COMPONENT_TYPES.wb_btn || componentData.cid == COMPONENT_TYPES.wb_is_post_event ||
    componentData.cid == COMPONENT_TYPES.wb_process) {
    //不能单纯的 覆盖这个样式 有的是这个生效 有的是commonAttr里的生效 styles中会使用item.styles 之后的版本不会再有这个属性 所有的属性都会在commonAttr里
    if(componentData.styles) {
      const styles = componentData.styles
      if(styles.color) commonAttr.color = styles.color
      if(styles.backgroundColor) commonAttr.backgroundColor = styles.backgroundColor
      if(styles.fontFamily) commonAttr.fontFamily = styles.fontFamily
      if(styles.lineHeight) commonAttr.lineHeight = styles.lineHeight
      if(styles.fontStyle) commonAttr.fontStyle = styles.fontStyle
      if(styles.fontWeight) commonAttr.fontWeight = styles.fontWeight
      if(styles.textAlign) commonAttr.textAlign = styles.textAlign
      if(styles.textDecoration) commonAttr.textDecoration = styles.textDecoration
      if(styles.letterSpacing) {
        if(!_.isNumber(styles.letterSpacing)) {
          commonAttr.letterSpacing = Number(styles.letterSpacing.split('px')[0])
        } else {
          commonAttr.letterSpacing = Number(styles.letterSpacing)
        }
      }
    }
    if(componentData.cid == COMPONENT_TYPES.wb_process) {
      if(isHasOwnProperty(commonAttr, 'borderBgColor')) {
        commonAttr.backgroundColor = commonAttr.borderBgColor
      }
      if(isHasOwnProperty(commonAttr, 'percentPaddingTB')) {
        commonAttr.padding = commonAttr.percentPaddingTB + ' ' + commonAttr.percentPaddingLR + ' ' + commonAttr.percentPaddingTB + ' ' + commonAttr.percentPaddingLR
      }
    }
  }
  if(componentData.styles) {
    if(isHasOwnProperty(componentData.styles, 'opacity')) {
      componentData.commonAttr.opacity = Number(componentData.styles.opacity)
    } else {
      componentData.commonAttr.opacity = 1
    }
  }
  if(componentData.cid == COMPONENT_TYPES.wb_btn) {
    if(isHasOwnProperty(componentData, 'bgUrl')) {
      commonAttr.bgUrl = componentData.bgUrl
      delete componentData.bgUrl
    }
    if(isHasOwnProperty(componentData, 'selectedBGUrl')) {
      commonAttr.selectedBgUrl = componentData.selectedBGUrl
      delete componentData.selectedBGUrl
    }
  }  else {
    delete componentData.styles
  }
}

function saveSiteDataBeforeDealData(components, siteData) {
  let componentData
  for(let j = 0, len = components.length; j < len; j++) {
    componentData = components[j]
    deleteDefaultAttr(componentData)
    if(componentData.cid == COMPONENT_TYPES.wb_text) {
      if(componentData.commonAttr.isHtml) {
        let html = componentData.commonAttr.text
        html = html.replace(/</g, "《")
        html = html.replace(/>/g, "》")
        componentData.commonAttr.text = html
      }
    }
    _.forEach(componentData.events, (event) => {
      if(event.controlId == CONTROL_TYPES.wb_activity_info) {
        siteData.activityInfo.isHave = true
        siteData.activityInfo.compId = componentData.id
      }
    })
    if(componentData.components && componentData.components.length > 0) {
      saveSiteDataBeforeDealData(componentData.components, siteData)
    }
  }
}
export function initComponent(data_, position, siteStatus){
  let copyData = _.cloneDeep(getComponentDataByCid(data_.cid))
  copyData.id = guid()
  _.merge(copyData, ADD_COMP_ATTR)
  if(!data_.conAttr) {
    data_.conAttr = {}
  }
  //组件中没有相对坐标就使用上一个点击组件的坐标
  if(!data_.conAttr.top) {
    data_.conAttr.top = position.top + 40
  }
  if(!data_.conAttr.left) {
    data_.conAttr.left = position.left
  }
  if(!data_.conStyles) {
    data_.conStyles = {}
  }
  _.forEach(copyData.conAttr, (val, attr) => {
    copyData.conStyles[attr] = getPxOVwByValue(val)
  })
  _.forEach(data_.conAttr, (val, attr) => {
    data_.conStyles[attr] = getPxOVwByValue(val)
  })
  _.merge(copyData, data_)

  copyData.conAttr.zIndex = parseInt(siteStatus.zIndex)
  copyData.active = true
  return copyData
}
//递归处理在删除组件的时候将组件的微博事件也删除掉
export function deleteComponentControl(commit, componentData){
  _.forEach(componentData.components, (componentData_) => {
    commit('wbComponents/deleteControl', componentData_.id, {root:true});
    if(componentData_.components && componentData_.components.length > 0){
      deleteComponentControl(commit, componentData_)
    }
  })
}
export function addComponentData(componentData, commit){
  commit('addComponent', componentData);
  commit('setActiveComponentId', componentData.id);
  //添加在组件中默认的微博事件
  if(isHasOwnProperty(componentData, 'oriEvents') && componentData.oriEvents.length > 0){
    _.forEach(componentData.oriEvents, ({controlId, eventType}) => {
      let controlData = componentData.controls ? componentData.controls[controlId] : null;
      let event = _.cloneDeep(getEventByControlId({controlId, type: eventType}));
      commit('addEvent', event);
      commit('wbComponents/setActiveWbData', componentData, {root:true});
      commit('wbComponents/addEventControlToCurrentControls',{controlId: event.controlId, controlData, id: componentData.id}, {root:true});
    })
  }
}
//递归处理在拷贝组件的时候将组件的微博事件也拷贝出来并赋予新的id与拷贝出来的id关联上
export function copyGroupComponentControls(commit, componentData){
  let compId
  let copyId
  _.forEach(componentData.components, (componentData_) => {
    copyId = componentData_.id
    compId = guid()
    componentData_.id = compId
    commit('wbComponents/addEventControlToControls', {copyId, compId}, {root:true});
    if(componentData_.components && componentData_.components.length > 0){
      copyGroupComponentControls(commit, componentData_)
    }
  })
}

function setControlElementsId(controls, controls_, componentMap) {
  _.forEach(controls, (controlEvents_, key) => {
    if(controlEvents_ && componentMap[key]) {
      if(!_.isArray(controlEvents_)) {
        controls_[key] = controlEvents_
        if(controlEvents_[CONTROL_TYPES.wb_reposts]) {
          _.forEach(controlEvents_[CONTROL_TYPES.wb_reposts].data.elements, (repostItem) => {
            if(repostItem.mid) {
              repostItem.mid = repostItem.mid.replace(/\s*/g,"")
            }
          })
        } else if(controlEvents_[CONTROL_TYPES.wb_lottery]) {
          _.forEach(controlEvents_[CONTROL_TYPES.wb_lottery].data.elements, (item, index) => {
            item.gift_id = index + 1
          })
        }
      }
    }
  })
}

//递归处理删除默认字段
function deleteDefaultAttr(componentData) {
  componentDataDeleteAttr(componentData);
  if(componentData.components && componentData.components.length > 0) {
    _.forEach(componentData.components, (componentData_) => {
      deleteDefaultAttr(componentData_)
    })
  }else{
    if(componentData.btn) {
      deleteDefaultAttr(componentData.btn)
    }
  }
}
const DELETE_COMP_ATTR = ["isActive","active","defaultValue","tabName","name","title"];
function componentDataDeleteAttr(componentData) {
  _.forEach(DELETE_COMP_ATTR, (attr) => {
    if(isHasOwnProperty(componentData, attr)) {
      delete componentData[attr]
    }
  })
  if(_.size(componentData.events) <= 0) {
    delete componentData.events
  }
  // 动画
  if(componentData.animate && !componentData.animate.isGsap && componentData.animate.animates.length == 0) {
    delete componentData.animate
  }
  let commonAttr = componentData.commonAttr
  let oriComponentData = getComponentDataByCid(componentData.cid)
  _.forEach(oriComponentData, (value, key) => {
    let oriCommonAttr = {}
    _.merge(oriCommonAttr, ADD_COMP_ATTR.commonAttr);
    _.merge(oriCommonAttr, oriComponentData.commonAttr);
    if(_.isObject(oriComponentData[key])){
      if(key == "commonAttr") {
        _.forEach(commonAttr, (value, key) => {
          if(_.isObject(oriCommonAttr[key])){
            if(_.isEqual(oriCommonAttr[key], value)) {
              delete commonAttr[key]
            }
          }else if(oriCommonAttr[key] == value && key!= "isVisible"){
            delete commonAttr[key]
          }
        })
      }
    }else if(componentData[key] == value && key!= "cid"){
      delete componentData[key]
    }
  })
  if(componentData.cid == COMPONENT_TYPES.wb_img) {
    delete componentData.commonAttr.alt
  }
  delete componentData.styles
  delete componentData.conStyles
  delete componentData.vueInjectContainer
}

export function getComponentDataByCid(cid) {
  return ComponentTypes[cid];
}
